<extend name="Base/common"/>

<block name="style">
    <link href="__CSS__/event.css" rel="stylesheet" type="text/css"/>
</block>
<block name="body">
<div class="content-body">
    <div class="col-md-12">
		<h2 class="content-title black">
	    	{$content.title}
	    </h2>
	</div>
	<div class="clearfix visible-md-block"></div>
	<div class="col-md-12 margin-bottom-10">
		<div class="meta" style="padding-bottom:10px;border-bottom: 4px solid #ec6b18;">
			<a style="padding-left:8px;" class="flag flag{$content.type_id}" href="{:U('Event/Index/index',array('type_id'=>$content['type_id']))}" title="{$content.type.title}">{$content.type.title}</a>
			发起人： <a href="{$content.user.space_url}" ucard="{$content.user.uid}">{$content.user.nickname}</a>
			发布时间：{$content.create_time|friendlyDate="mohu"}&nbsp;
			
			<php>if($content['uid'] == is_login() || is_administrator(is_login())){</php>
                <if condition="time() lt $content['eTime']">
                    <a id="endEvent" class="gray"><i class="iconfont bj fs16">&#xe623;</i>&nbsp;{:L('_OVER_AHEAD_')}</a>
                </if>
                <a href="{:U('edit',array('id'=>$content['id']))}" class="gray"><i class="iconfont bj">&#xe641;</i>&nbsp;{:L('_EVENT_EDIT_')}</a>
                <a id="delEvent" class="gray"><i class="iconfont bj fs16">&#xe61c;</i>&nbsp;{:L('_EVENT_DELETE_')}</a>
            <php>}</php>
			<if condition="($content['status'] eq 1)&&($content['deadline'] gt time())">
            {:W('Weibo/Share/shareBtn',array('param'=>array('title'=>$content['title'],'content'=>$content['explain'],'img'=>getThumbImageById($content['cover_id'],160,160),'from'=>$MODULE_ALIAS,'site_link'=>U('Event/index/detail',array('id'=>$content['id']))),'text'=>'分享','css' =>array('style'=>'font-size:16px;','class'=>'gray')))}
            </if>
			<dl>
				<dd>{:Hook('support',array('app'=>'Event',table=>'detail','row'=>$content['id'],'uid'=>$content['uid'],'jump'=>'Event/index/detail'))}</dd>
				<dd><i class="iconfont ">&#xe631;</i> {$content.reply_count}</dd>
				<dd><i class="iconfont fs24" style="vertical-align: -4px;">&#xe63a;</i> {$content.view_count}</dd>
			</dl>
		</div>
	</div>
	<div class="clearfix visible-md-block"></div>
	<div class="col-md-12 margin-top-15">
		<div class="event-detail">
			<div class="time">
				活动时间：{:date('Y-m-d',$content['sTime'])} 至 {:date('Y-m-d',$content['eTime'])}
				<span class="other">{:date('Y-m-d H:i',$content['deadline'])} 报名截止</span>
			</div>
			<div class="rs">
				截止今日已经有<b>{$content.signCount}</b>人报名
				<span class="other">限定 {$content.limitCount} 人报名</span>
			</div>
			<div class="sharebtn">
					<div class="pull-left">分享到：</div>
					<div class="bdsharebuttonbox share" style="background:#f5f5f5">
						
						<a href="#" class="qzone" data-cmd="qzone" title="分享到QQ空间"></a>
						<a href="#" class="tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
						<a href="#" class="weixin" data-cmd="weixin" title="分享到微信"></a>
						<a href="#" class="tsina" data-cmd="tsina" title="分享到新浪微博"></a>
					</div>
					
					<script>
						window._bd_share_config = {
							"common": {
								"bdSnsKey": {},
								"bdText": "",
								"bdMini": "2",
								"bdMiniList": false,
								"bdPic": "",
								"bdStyle": "1",
								"bdSize": "24"
							},
							"share": {}
						};
						with(document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
					</script>
					<style>
						#bdshare_weixin_qrcode_dialog {
							min-height: 326px;
						}
					</style>

			</div>
			<div class="bm">
				<php>
                if($content['uid'] != is_login()){
                    if(!$check_isSign){
                    	if($content['deadline'] < time()){
				</php>
                        <a class="bmbtn" href="javascript:" onclick="toast.error({:L('')})">{:L('_REGISTRATION_HAS_OVER_')} </a>
                     	<php>}else{</php>
                                <if condition="is_login() eq 0">
                                    <a class="bmbtn" href="javascript:" onclick="toast.error({:L('_ERROR_REGISTER_AFTER_LOGIN_')})">{:L('_REGISTER_OP_')} </a>
                                <else/>
                                    <if condition="check_auth('Event/Index/doSign')">
                                        <a class="bmbtn event_sign" href="{:U('ajax_sign',array('event_id'=>$content['id']))}">{:L('_REGISTER_OP_')} </a>
                                    </if>
                                </if>
                        <php>}
                    }else{</php>
                        <a class="bmbtn" href="javascript:" id="unSign">{:L('_REGISTER_CANCEL_')} </a>
                        
                    <php>}</php>
                <php>}</php>
			</div>
		</div>
	</div>
	<div class="clearfix visible-md-block"></div>
	<div class="col-md-12">
		<h2>{:L('_EVENT_DETAIL_')}：</h2>
		<div class="signature word-wrap">
			{$content.explain|render}
		</div>
	</div>
	<div class="clearfix visible-md-block"></div>
	<div class="col-md-12 margin-top-15">
		{:hook('localComment', array('path'=>"Event/event/$content[id]", 'uid'=>$content['uid'],'count_model'=>'event','count_field'=>'reply_count','this_url'=>'event/index/detail'))}
	</div>
	<php>if(ACTION_NAME == 'detail' ){</php>
	<div class="col-md-12 margin-top-15">
    <h2 class="event_type_name">{:L('_EVENT_IN_PEOPLE_')} ({$content.attentionCount}{:L('_PEER_')})
    	<a class="pull-right" href="{:U('member',array('id'=>$content['id']))}" style="font-size: 14px;margin-right: 10px;color: #EC6914">查看全部</a>
    </h2>
    <ul class="event-member">
        <volist name="content['member']" id="vo" offset="0" length="20">
            <li>
                <div class="pull-left img">
                	{$vo.create_time}<a href="{$vo.space_url}"><img ucard="{$vo.id}" src="{$vo.avatar64}" class="avatar-img" style="width: 38px"/></a>
                </div>
                <div class="pull-left name">
                	<a href="{$vo.space_url}">{$vo.nickname}</a>
                	<p>{:date('m月d日',$vo['bmtime'])}</p>
                </div>
            </li>
        </volist>
    </ul>

	</div>
	<php>}</php>
	<div class="col-md-12 margin-top-15">
    	<div class="events">
			<div class="event-title">
				<h3 class="flag3">精选活动</h3><span class="line flag3"></span><a href="javascript:;" class="more more3">More</a>
			</div>
			<div class="event-list">
				<ul>
					<volist name="rec_event" id="rec">
						<li><a href="{:U('Event/Index/detail',array('id'=>$rec['id']))}">{$rec.title}</a><if condition="time() lt $rec['eTime']"><span class="status" style="background: #ec6b18;">正在进行</span><else/><span class="status" style="background: #666;">已结束</span></if><span class="num">{$rec.signCount}报名</span></li>
					</volist>
					
				</ul>
			</div>
		</div>
	</div>
</div>
</block>

<block name="script">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <script>
        $(function () {
            $('#top_nav >li >a ').mouseenter(function () {
                $('.children_nav').hide();
                $('#children_' + $(this).attr('data')).show();
            });


            $('.event_sign').magnificPopup({
                type: 'ajax',
                overflowY: 'scroll',
                modal: true,
                callbacks: {
                    ajaxContentAdded: function () {
                        console.log(this.content);
                    }
                }
            });



            /**
             * 取消报名
             * */
            $('#unSign').click(function () {
                if (confirm("{:L('_PROMPT_CANCEL_')}{:L('_QUESTION_')}")) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/unSign')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.reload();
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
            /**
             * 删除活动事件
             * */
            $('#delEvent').click(function () {
                if (confirm("{:L('_PROMPT_DELETE_')}{:L('_QUESTION_')}")) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/doDelEvent')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.href = "{:U('index')}";
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
            /**
             * 提前结束活动点击事件
             */
            $('#endEvent').click(function () {
                if (confirm("{:L('_PROMPT_OVER_')}{:L('_QUESTION_')}")) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/doEndEvent')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.reload();
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
        })
    </script>

</block>

